import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main, sim_items
from util import *

class Potion(sim_items.Potion):
    def __init__(self):
        sim_items.Potion.__init__(self, "farsight", "!",
                ('see', 'far'),
                idDescription="This rare potion produces an out of body "\
                    "effect that lets one observe, or at least be aware of, "\
                    "distant places and events, so long as the viewer would "\
                    "be able to perceive them normally.")

    def quaff(self, quaffer):
        if quaffer is not main.player:
            parole.error('Nonplayer quaffed potion of farsight... cannot '
                         'handle this!')
            return
        main.mapFrame.bindVisibilityToFOV(None, 0)
        main.mapFrame.getMap().update()
        quaffer.farsight = True

        main.schedule.add(sim.Event('expire effect', main.schedule.time + 30000,
            (self,), dests=[self]))
        main.schedule.add(sim.Event('statusNote+', main.schedule.time,
            (main.player, 'farsight'), dests=[main.player]))
        main.schedule.add(sim.Event('statusNote-', main.schedule.time + 30000,
            (main.player, 'farsight'), dests=[main.player]))
        main.player.identify(self)

    def listen(self, event):
        sim_items.Potion.listen(self, event)

        if event.id == 'expire effect' and event.args[0] is self:
            main.player.farsight = False
            main.player.bindMe()

#========================================
thingClass = Potion
